import { Destroyable, react, reactJson, Event, track, HasOwner, createNextAnimateFrameEvent } from "xbsj-xe2/dist-node/xe2-base-utils";
import { MyProjectManager } from "../MyProjectManager";
import { ESGeoLineString, ESGltfModel, ESGeoPolygon } from "esobjs-xe2-plugin/dist-node/esobjs-xe2-plugin-main";
import { ObjResettingWithEvent, SceneObject } from 'xbsj-xe2/dist-node/xe2-base-objects';
import { ElMessage } from "element-plus";
import { ModelserManager } from ".";
import { ESRtsPolygon } from "../esobjs/ESRtsPolygon";
import { ESGeoExtrudedPolygonUFMS } from "../esobjs/ESGeoExtrudedPolygonUFMS";

export class FreeDrawingResettting extends Destroyable {
    constructor(modelserManager: ModelserManager, owner: MyProjectManager) {
        super();
        const viewer = owner.activeViewer
        if (!viewer) return;
      
        const sceneObject = owner.createSceneObject(ESGeoExtrudedPolygonUFMS) as ESGeoExtrudedPolygonUFMS
        sceneObject.fillColor = [1, 0, 0, 0.5];
        sceneObject.name = "自由绘制"
        // sceneObject.absoluteBottom = false
        // sceneObject.absoluteCeilling = true
        // sceneObject.bottom = 0
        // sceneObject.ceilling = 10
        // sceneObject.operation = "1"

        owner.modelserPropSceneTree = {
            createOrEdit: 'create',
            propType:"freeDrawing",
            sceneObject: sceneObject,
        }

        this.dispose(()=>{
            if (!owner.modelserSceneTreeWrapper?.getTreeItemFromSceneObjId(sceneObject.id)) {
                sceneObject.editing = false
                sceneObject && owner.destroySceneObject(sceneObject);
                owner.modelserPropSceneTree = undefined
            }
        })
    }
}